Skip to content

Conversation

@Leo6Leo
Copy link
Contributor

@Leo6Leo Leo6Leo commented Nov 18, 2025

Description

Visiting Group Detail Page > RoleBindings will show error: XXX.every is not a function

How to reproduce?

  1. Create a group, you can just use the default yaml without changing anything
  2. Go to Groups and click on the group you just created. (If you are using the default yaml, its name should be example)
  3. The page will show "Something wrong happened d.every is not a function" And the detailed react error is displayed to user.

This pr fixed the issue mentioned above.

Root Cause

The code tried to call .every() on an object, which caused the crash. Converting it to array and adding the check to return early if it's not an array solve the problem.

…rray and object formats. Update tableFilters to ensure values.all is an array before processing. This improves filter robustness across components.
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 18, 2025
@openshift-ci-robot openshift-ci-robot added jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Nov 18, 2025
@openshift-ci-robot
Copy link
Contributor

@Leo6Leo: This pull request references Jira Issue OCPBUGS-65690, which is invalid:

  • expected the bug to target the "4.21.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

In response to this:

Description

Visiting Group Detail Page > RoleBindings will show error: XXX.every is not a function

How to reproduce?

  1. Create a group, you can just use the default yaml without changing anything
  2. Go to Groups and click on the group you just created. (If you are using the default yaml, its name should be example)
  3. The page will show "Something wrong happened d.every is not a function" And the detailed react error is displayed to user.

This pr fixed the issue mentioned above.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@Leo6Leo
Copy link
Contributor Author

Leo6Leo commented Nov 18, 2025

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Nov 18, 2025
@openshift-ci-robot
Copy link
Contributor

@Leo6Leo: This pull request references Jira Issue OCPBUGS-65690, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.21.0) matches configured target version for branch (4.21.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @yapei

In response to this:

/jira refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot requested review from jhadvig, spadgett and yapei November 18, 2025 14:40
@openshift-ci openshift-ci bot added the component/core Related to console core functionality label Nov 18, 2025
@coderabbitai
Copy link

coderabbitai bot commented Nov 18, 2025

Walkthrough

The PR normalizes filter handling across RBAC and table filter components to support both array and non-array input forms. It adds guards to ensure array checks before operations and converts single objects to arrays when needed, improving robustness against inconsistent filter input types.

Changes

Cohort / File(s) Summary
RBAC filter normalization
frontend/public/components/RBAC/bindings.tsx, frontend/public/components/RBAC/role.jsx
Normalize staticFilters input to array form by wrapping non-array values; update filtering logic to iterate over normalized filtersArray while preserving existing per-filter handling via filtersMap.
Table filter array guards
frontend/public/components/factory/table-filters.ts
Add defensive checks to confirm values.all is an array before filtering operations in alerts, observe-rules, labels, and observe-target-labels filters; return true when array requirement is not met.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • The changes follow a consistent pattern of defensive normalization across multiple files
  • Array guards are straightforward conditional checks with no complex logic
  • Homogeneous application of the same normalization principle reduces reasoning overhead per file
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci-robot
Copy link
Contributor

@Leo6Leo: This pull request references Jira Issue OCPBUGS-65690, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.21.0) matches configured target version for branch (4.21.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @yapei

In response to this:

Description

Visiting Group Detail Page > RoleBindings will show error: XXX.every is not a function

How to reproduce?

  1. Create a group, you can just use the default yaml without changing anything
  2. Go to Groups and click on the group you just created. (If you are using the default yaml, its name should be example)
  3. The page will show "Something wrong happened d.every is not a function" And the detailed react error is displayed to user.

This pr fixed the issue mentioned above.

Root Cause

The code tried to call .every() on an object, which caused the crash. Converting it to array and adding the check to return early if it's not an array solve the problem.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@Leo6Leo Leo6Leo changed the title [WIP] OCPBUGS-65690: Visiting Group Detail Page > RoleBindings will show error OCPBUGS-65690: Visiting Group Detail Page > RoleBindings will show error Nov 18, 2025
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 18, 2025
@Leo6Leo
Copy link
Contributor Author

Leo6Leo commented Nov 18, 2025

Code Review
/assign @rhamilto @logonoff

Copy link
Member

@logonoff logonoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Nov 18, 2025
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 18, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Leo6Leo, logonoff

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 18, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
frontend/public/components/RBAC/role.jsx (1)

286-294: Add explicit return for missing filter handlers.

The every() callback returns undefined when filtersMap[filterKey] doesn't exist, causing the filter to fail and incorrectly exclude data.

Apply this diff:

     return data.filter((binding) => {
       return filtersArray.every((filter) => {
         const filterKey = Object.keys(filter)[0];
         const filterValue = filter[filterKey];

         // Use the table filter function if it exists
         if (filtersMap[filterKey]) {
           return filtersMap[filterKey](filterValue, binding);
         }
+        // If no filter exists for this key, pass the item through
+        return true;
       });
     });
frontend/public/components/RBAC/bindings.tsx (1)

304-312: Add explicit return for missing filter handlers.

This has the same issue as role.jsx: the every() callback returns undefined when a filter key is not found in filtersMap, causing valid data to be incorrectly excluded.

Apply this diff:

     return data.filter((binding) => {
       return filtersArray.every((filter) => {
         const filterKey = Object.keys(filter)[0];
         const filterValue = filter[filterKey];

         // Use the table filter function if it exists
         if (filtersMap[filterKey]) {
           return filtersMap[filterKey](filterValue, binding);
         }
+        // If no filter exists for this key, pass the item through
+        return true;
       });
     });
🧹 Nitpick comments (1)
frontend/public/components/RBAC/bindings.tsx (1)

293-313: Consider extracting the staticFilters logic into a shared utility.

The staticFilters normalization and filtering logic is duplicated between this file and role.jsx. Extracting it into a reusable function would improve maintainability.

Example approach:

// In a shared utilities file
export const applyStaticFilters = (data, staticFilters, filtersMap) => {
  if (!staticFilters || !data) {
    return data;
  }

  const filtersArray = Array.isArray(staticFilters) ? staticFilters : [staticFilters];

  return data.filter((item) => {
    return filtersArray.every((filter) => {
      const filterKey = Object.keys(filter)[0];
      const filterValue = filter[filterKey];

      if (filtersMap[filterKey]) {
        return filtersMap[filterKey](filterValue, item);
      }
      return true;
    });
  });
};

Then use it in both files:

const filteredData = React.useMemo(() => {
  return applyStaticFilters(data, staticFilters, tableFilters(false));
}, [data, staticFilters]);
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between f0cb82b and ef10746.

📒 Files selected for processing (3)
  • frontend/public/components/RBAC/bindings.tsx (1 hunks)
  • frontend/public/components/RBAC/role.jsx (1 hunks)
  • frontend/public/components/factory/table-filters.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**

⚙️ CodeRabbit configuration file

-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.

Files:

  • frontend/public/components/RBAC/bindings.tsx
  • frontend/public/components/RBAC/role.jsx
  • frontend/public/components/factory/table-filters.ts
🔇 Additional comments (6)
frontend/public/components/RBAC/role.jsx (1)

282-283: LGTM! Normalization handles both array and object forms.

The conversion correctly addresses the root cause of the "every is not a function" error by ensuring staticFilters is always treated as an array.

frontend/public/components/RBAC/bindings.tsx (1)

300-301: LGTM! Consistent normalization approach.

The staticFilters normalization correctly handles both array and object inputs, matching the implementation in role.jsx.

frontend/public/components/factory/table-filters.ts (4)

56-62: LGTM! Array guard prevents runtime errors.

The array check correctly prevents calling .every() on non-array values. Returning true (include item) when the filter is malformed is a reasonable default that avoids hiding data from users.


64-70: LGTM! Consistent array guard.

The guard matches the pattern used in the alerts filter, maintaining consistency across the codebase.


72-75: LGTM! Defensive array check prevents errors.

The inline array check ensures .every() is only called on arrays. The short-circuit evaluation provides a safe fallback, consistent with the other filter guards.


99-105: LGTM! Completes the defensive pattern.

The array guard follows the same pattern as the alerts and observe-rules filters, ensuring consistent error handling across all label-based filters.

@Leo6Leo
Copy link
Contributor Author

Leo6Leo commented Nov 18, 2025

The error log seems irrelevant to the code change in this PR. Might be flaky tests
/retest

@Leo6Leo
Copy link
Contributor Author

Leo6Leo commented Nov 18, 2025

[FAILED] URL: https://download.cypress.io/desktop/14.2.1?platform=linux&arch=x64
[FAILED] Error: Failed downloading the Cypress binary.
[FAILED] Response code: 500
[FAILED] Response message: Internal Server Error

The cypress server is currently down. Hold for retesting.

@Leo6Leo
Copy link
Contributor Author

Leo6Leo commented Nov 19, 2025

/retest

@Leo6Leo
Copy link
Contributor Author

Leo6Leo commented Nov 19, 2025

/retest-required

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 20, 2025

@Leo6Leo: all tests passed!

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. component/core Related to console core functionality jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants